package com.xukehong.demo.controller;

import com.xukehong.demo.service.WebSocketService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.websocket.OnClose;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Author: xkh
 * @Date: 2019/4/12 16:09
 * @Version 1.0
 */
@Slf4j
@RestController
@RequestMapping("/websocket")
@Api(tags = "websocket")
public class WebSocketController {

    @Autowired
    private WebSocketService webSocketService;
    //推送数据接口
    @ResponseBody
    @RequestMapping("/push/{name}")
    public void push(@PathVariable String name,String message){
        log.info("开始推送消息!"+message);
        webSocketService.AppointSending(name,message);
    }

}
